I created a table “article” with columns articleId and article_content. I also used html editor for “article_content” column. When I tried to save I got the following error. It was resolved by adding [AllowHtml] to article_content property in class.
Don’t forget to include the namespace using System.Web.Mvc.
Problem:
Server Error in '/' Application.
A potentially dangerous Request.Form value was detected from the client (Description="<pre style="font-fam...").
Description: ASP.NET has detected data in the request that is potentially dangerous because it might include HTML markup or script. The data might represent an attempt to compromise the security of your application, such as a cross-site scripting attack. If this type of input is appropriate in your application, you can include code in a web page to explicitly allow it. For more information, see http://go.microsoft.com/fwlink/?LinkID=212874.
Exception Details: System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (Description="<pre style="font-fam...").
Source Error:An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Solution:
namespace infinetsoft.Areas.Admin.Models
{
using Hammock.Attributes.Validation;
using System;
using System.Collections.Generic;
using System.Web.Mvc;
public partial class Article
{
public int ArticleId { get; set; }
[AllowHtml]
[Required]
public string article_content { get; set; }
}
}
after allowHtml property for the property in the class. I have tried to save it is working fine.
Post your comments / questions
Recent Article
- How to create custom 404 error page in Django?
- Requested setting INSTALLED_APPS, but settings are not configured. You must either define..
- ValueError:All arrays must be of the same length - Python
- Check hostname requires server hostname - SOLVED
- How to restrict access to the page Access only for logged user in Django
- Migration admin.0001_initial is applied before its dependency admin.0001_initial on database default
- Add or change a related_name argument to the definition for 'auth.User.groups' or 'DriverUser.groups'. -Django ERROR
- Addition of two numbers in django python
Related Article